#ifndef PROPERTY_SET_PRIVATE_H
#define PROPERTY_SET_PRIVATE_H
#include <qmap.h>
#include "PropertySet.h"

#define SET_PROPERTY_BLOCK\
	bool containProperty(const QString& key)\
    {\
        return propertySet.contains(key);\
    }\
    void insertProperty(const QString& key,const QString& value)\
    {\
        propertySet.insert(key,value);\
    }\
	QString getProperty(const QString& key,const QString& defValue)\
	{\
		if(containProperty(key))\
			return propertySet[key];\
		return defValue;\
	}\
	QStringList getPropertyNameList()const\
	{\
		return propertySet.keys();\
	}\
	QJsonObject toJson()\
	{\
		QJsonObject object;\
		auto itr = propertySet.begin();\
        while(itr != propertySet.end())\
		{\
            object[itr.key()] = itr.value();\
			itr++;\
		}\
		return object;\
	}\
	bool fromJson(const QJsonObject& json)\
	{\
		auto keys = json.keys();\
		foreach(auto key,keys)\
		{\
			auto value = json[key];\
			if(!value.isString())\
				return false;\
			insertProperty(key,value.toString());\
		}\
		return true;\
	}\
	QMap<QString,QString> propertySet;

#endif
